#include "CustomBinaryStream.h"

void CustomBinaryStream::write(const void* data, size_t size) 
{
	// 获取当前buffer的大小作为写入起始位置
	auto offset = buffer.size();
	// 扩展buffer以容纳新数据
	buffer.resize(offset + size);
	// 复制数据
	std::memcpy(buffer.data() + offset, data, size);
}

char* CustomBinaryStream::getBuffer()
{
	return (char*)buffer.data();
}

std::vector<uint8_t> &CustomBinaryStream::getDataRef()
{
    return buffer;
}

size_t CustomBinaryStream::getByteLength()
{ 
	return buffer.size(); 
}

